﻿Imports BUS
Imports DTO
Public Class frmGiaoDienQuyen : Inherits DevComponents.DotNetBar.Office2007Form

    Private Sub frmGiaoDienQuyen_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Reload()
    End Sub

    Private Sub Reload()
        Dim lquyen As List(Of CQuyenDTO) = New CQuyenBUS().LoadQuyen()
        DataGridViewXQuyen.Rows.Clear()
        Dim stt = 0
        For Each quyen As CQuyenDTO In lquyen
            stt += 1
            DataGridViewXQuyen.Rows.Add(stt, quyen.Ma, New CQuyenHanBUS().LayTenQuyenTheoMa(quyen.MaQuyenHan), quyen.RibbonBarDuLieu, quyen.RibbonBarQuanLySach, quyen.RibbonBarMuonTraSach, quyen.RibbonBarThuTienPhat, quyen.RibbonBarNhanVien, quyen.RibbonBarTheThuVien, quyen.RibbonBarTimKiemTheoSach, quyen.RibbonBarTimKiemTheoDocGia, quyen.RibbonBarTinhHinhChoMuonSach, quyen.RibbonTabIemAdmin, quyen.RibbonTabItemBlackAdmin)
        Next
    End Sub

    Private Sub ButtonXCapNhat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonXCapNhat.Click
        Dim dto As CQuyenDTO
        Dim kt As Boolean
        For Each item As DataGridViewRow In DataGridViewXQuyen.Rows
            dto = New CQuyenDTO()
            dto.Ma = item.Cells("clMa").Value
            dto.RibbonBarDuLieu = item.Cells("clQuanLyDuLieu").Value
            dto.RibbonBarQuanLySach = item.Cells("clQuanLySach").Value
            dto.RibbonBarMuonTraSach = item.Cells("clMuonTraSach").Value
            dto.RibbonBarThuTienPhat = item.Cells("clThuTienPhat").Value
            dto.RibbonBarNhanVien = item.Cells("clNhanVien").Value
            dto.RibbonBarTheThuVien = item.Cells("clTheThuVien").Value
            dto.RibbonBarTimKiemTheoSach = item.Cells("clTimKiemTheoSach").Value
            dto.RibbonBarTimKiemTheoDocGia = item.Cells("clTimKiemTheoDocGia").Value
            dto.RibbonBarTinhHinhChoMuonSach = item.Cells("clBaoCao").Value
            dto.RibbonTabIemAdmin = item.Cells("clAdmin").Value
            dto.RibbonTabItemBlackAdmin = item.Cells("clBlackAdmin").Value
            kt = New CQuyenBUS().UpdateQuyen(dto)
        Next
        Reload()
    End Sub
End Class